<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Incidente Details</f:facet>


        <s:decorate id="data" template="layout/display.xhtml">
            <ui:define name="label">Data</ui:define>
            <h:outputText value="#{incidenteHome.instance.data}"/>
        </s:decorate>

        <s:decorate id="descricao" template="layout/display.xhtml">
            <ui:define name="label">Descricao</ui:define>
            <h:outputText value="#{incidenteHome.instance.descricao}"/>
        </s:decorate>

        <s:decorate id="prioridade" template="layout/display.xhtml">
            <ui:define name="label">Prioridade</ui:define>
            <h:outputText value="#{incidenteHome.instance.prioridade}"/>
        </s:decorate>

        <s:decorate id="status" template="layout/display.xhtml">
            <ui:define name="label">Status</ui:define>
            <h:outputText value="#{incidenteHome.instance.status}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/IncidenteEdit.xhtml"
                    id="edit"
                 value="Edit"/>

        <s:button view="/#{empty incidenteFrom ? 'IncidenteList' : incidenteFrom}.xhtml"
                    id="done"
                 value="Done"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Criador</h:panelGroup>
        </f:facet>
    <div class="association" id="criadorParent">

        <h:outputText value="There is no criador associated with this incidente."
                   rendered="#{incidenteHome.instance.criador == null}"/>

        <rich:dataTable var="_usuario"
                   value="#{incidenteHome.instance.criador}"
                rendered="#{incidenteHome.instance.criador != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="criadorTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_usuario.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Login</f:facet>
                <h:outputText value="#{_usuario.login}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Tipo</f:facet>
                <h:outputText value="#{_usuario.tipo}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewusuario"
                     value="View"
                      view="/Usuario.xhtml">
                    <f:param name="usuarioId"
                           value="#{_usuario.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Respostas</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="respostasChildren">

        <h:outputText value="There are no respostas associated with this incidente."
                   rendered="#{empty incidenteHome.respostas}"/>

        <rich:dataTable value="#{incidenteHome.respostas}"
                       var="_resposta"
                  rendered="#{not empty incidenteHome.respostas}"
                rowClasses="rvgRowOne,rvgRowTwo"
                        id="respostasTable">
            <rich:column sortBy="#{_resposta.id}">
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_resposta.id}"/>
            </rich:column>
            <rich:column sortBy="#{_resposta.data}">
                <f:facet name="header">Data</f:facet>
                <h:outputText value="#{_resposta.data}"/>
            </rich:column>
            <rich:column sortBy="#{_resposta.texto}">
                <f:facet name="header">Texto</f:facet>
                <h:outputText value="#{_resposta.texto}"/>
            </rich:column>
            <h:column>
                <f:facet name="header">Action</f:facet>
                <s:link id="selectresposta"
                     value="Select"
                      view="/Resposta.xhtml">
                    <f:param name="respostaId"
                            value="#{_resposta.id}"/>
                    <f:param name="respostaFrom" value="Incidente"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Add resposta"
                view="/RespostaEdit.xhtml">
            <f:param name="incidenteId"
                    value="#{incidenteHome.instance.id}"/>
            <f:param name="respostaFrom" value="Incidente"/>
        </s:button>
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
